home *** CD-ROM | disk | FTP | other *** search
/ 220 Jogos / 220 jogos.iso / tetris / tetron / SOURCE / OPENGL.H < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-13  |  4.5 KB  |  141 lines

  1. //----------------------------------------------------------------------------------------
  2. //----------------------------------------------------------------------------------------
  3. //
  4. //        Filename        :    OpenGL.h
  5. //        Description        :    Header file for OpenGL Class
  6. //        Author            :   Marnich van Rensburg (2002)
  7. //
  8. //----------------------------------------------------------------------------------------
  9. //----------------------------------------------------------------------------------------
  10.  
  11. #include <windows.h>    // Windows Functions
  12. #include <stdio.h>        // Standard Input\Output
  13. #include <stdarg.h>        // Variable Argument Routines
  14. #include <time.h>        // for time function
  15. #include <stdlib.h>        // For srand and rand functions
  16.  
  17. #include <gl\gl.h>        // OpenGL32 Library
  18. #include <gl\glu.h>        // GLu32 Library
  19. #include <gl\glaux.h>    // GLaux Library
  20.  
  21. #include "container.h"
  22. #include "tetramino.h"
  23. #include "gamestats.h"
  24. #include "timer.h"
  25. #include "top10.h"
  26.  
  27. #ifndef OPENGL_H
  28. #define OPENGL_H
  29.  
  30. //----------------------------------------------------------------------------------------
  31. //        External Globals
  32. //----------------------------------------------------------------------------------------
  33.  
  34. extern bool SoundActive;
  35. extern bool StarFieldActive;
  36.  
  37.  
  38. //----------------------------------------------------------------------------------------
  39. //        Constants
  40. //----------------------------------------------------------------------------------------
  41.  
  42. //Texture Filter Types
  43. #define NEAREST        0        // Create nearest Filtered Texture (Low quality / Fast rendering)
  44. #define LINEAR        1        // Create Linear Filtered Texture (Med quality / Med rendering)
  45. #define MIPMAP        2        // Create MipMapped Texture (High quality / Slow rendering)
  46.         
  47. #define NUMBER_OF_TEXTURES    14
  48. #define NUMBER_OF_STARS        200
  49.  
  50.  
  51. struct Star
  52. {
  53.     float x, y;
  54. };
  55.  
  56. //----------------------------------------------------------------------------------------
  57. //    Class Definition for OpenGL Class
  58. //----------------------------------------------------------------------------------------
  59.  
  60. class OpenGL
  61. {
  62.     //---------------------- Public -------------------------
  63.  
  64.     public:
  65.         void DebugVal(float val);
  66.  
  67.  
  68.         OpenGL();        //Constructor
  69.         //Text
  70.         void SetTextBase(int Base);
  71.         GLvoid Print(GLint x, GLint y, const char *fmt, ...);
  72.  
  73.         //Init
  74.         bool CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag);
  75.         bool InitGL();
  76.         void SetFullScreen(bool fullscreen);
  77.         bool GetFullScreen() const;
  78.         
  79.         //Render
  80.         void RenderStartScreen(Top10& ref_HS);
  81.  
  82.         void RenderStart();
  83.         void RenderGameTitle(float x, float y);
  84.         void RenderContainer(Container& r_Container);
  85.         void RenderNextPreview(Tetramino& ref_TetNext);
  86.         void RenderRotationArrows(unsigned char UserAction);
  87.         void RenderDropArrow(char Start, char End, bool DropState);
  88.         void RenderGameStats(GameStats& Stats);
  89.         void RenderGameOver(char Mode[4]);
  90.         void RenderHighScoreScreen(char Name[25], char CursorPos, unsigned int Score);
  91.         void RenderStarField();
  92.         void RenderEnd();
  93.  
  94.         friend LRESULT CALLBACK WndProc(HWND   hWnd, UINT   uMsg, WPARAM wParam, LPARAM lParam);
  95.         HDC GethDC() const;
  96.         HWND GethWnd() const; 
  97.         GLvoid ReSizeGLScene(GLsizei width, GLsizei height);
  98.         
  99.         //Shutdown
  100.         GLvoid KillGLWindow();
  101.         void ErrorMsg(char *msg);
  102.  
  103.     //---------------------- Protected -------------------------
  104.  
  105.     protected:
  106.  
  107.         HDC       hDC;        // Private GDI Device Context
  108.         HGLRC     hRC;        // Permanent Rendering Context
  109.         HWND      hWnd;       // Holds Our Window Handle
  110.         HINSTANCE hInstance;  // Holds The Instance Of The Application
  111.         bool      FullScreen; // Fullscreen Flag Set To Fullscreen Mode By Default
  112.  
  113.  
  114.     //---------------------- Private -------------------------
  115.  
  116.     private:
  117.         void DrawFace(char Type);        //Draws a textured quad based on type val passed
  118.         void DrawGraphLine(float x, float y, float z, float Length);
  119.  
  120.         //Lights
  121.         GLfloat LightAmbient[4];
  122.         GLfloat LightDiffuse[4];
  123.         GLfloat LightPosition[4];
  124.  
  125.         GLuint    Texture[NUMBER_OF_TEXTURES];        // Storage Structure For Textures
  126.         AUX_RGBImageRec* LoadBMP(char *Filename);    // Loads A Bitmap Image
  127.         bool LoadGLTextures();                        // Load Bitmaps And Convert To Textures
  128.         
  129.         //Font
  130.         GLuint fTexture[1];            //Stores the font texture
  131.         GLuint fBase;
  132.         int    fWidth, fHeight, fSpacing, fStartPos, fxCount, fyCount, fdWidth, fdHeight;
  133.         GLvoid LoadFont();
  134.  
  135.         Timer SFTmr;
  136.         Star StarField[NUMBER_OF_STARS];
  137.         void DrawStar(float x, float y, float z);
  138.  
  139. };//Class OpenGL
  140.  
  141. #endif;